
#pragma once

#include "ttg/pipeline.h"
#include <cmath>
using namespace ttg;
using namespace ttg::pipeline;

static double wasteTime(double x) {
	double r = 1.0;
	if (x > 1e6)
		for (int i = 0; i < 100; i++)
			r += wasteTime(x / 100);
	else {
		int y = (int)x;
		for (int j = 0; j < 100000; j++)
			for (int i = 0; i < y; i++) {
				r += sin((double)i);
			}
	}
	return x * r / r;
}

template <class T>
class TimeWasterNode: public Node<pair<double, T>, pair<double, T> > {
protected:
	virtual void process(pair<double, T> data) {
		data.first = wasteTime(data.first);
		postWaste(data.first, data.second);
	}
	virtual void postWaste(double, const T &) {}
	virtual long getDifficulty(pair<double, T> data) {
		if (data.first <= 2e9)
			return (long)data.first;
		else
			return 2147483647;
	}
};
